var t = getApp();

Page({
    data: {
        myConcern: "",
        announceList: "",
        broadcastlist: "",
        allLivelistData: [],
        apiType: "recommend",
        playBackData: "",
        isLoadMore: !0,
        page: 1,
        total_page: 0,
        active: 2,
        playBackShow: !1,
        myConcern_activitys1: [],
        myConcern_activitys2: [],
        allLivelistData_activitys1: [],
        allLivelistData_activitys2: [],
        recommendData_activitys1: [],
        recommendData_activitys2: [],
        broadcastlist_activitys1: [],
        broadcastlist_activitys2: [],
        announceList_activitys1: [],
        announceList_activitys2: [],
        playBackData_activitys1: [],
        playBackData_activitys2: [],
        recommendData: [],
        live_search: "",
        my_colOneHeight: 0,
        my_colTwoHeight: 0,
        re_colOneHeight: 0,
        re_colTwoHeight: 0,
        br_colOneHeight: 0,
        br_colTwoHeight: 0,
        an_colOneHeight: 0,
        an_colTwoHeight: 0,
        pl_colOneHeight: 0,
        pl_colTwoHeight: 0,
        all_colOneHeight: 0,
        all_colTwoHeight: 0,
        cate_id: ""
    },
    onLoad: function(t) {
        console.log(t.id, 4444444444), t.id && this.setData({
            cate_id: t.id
        }), this.getRecommend(), this.getBanner(), this.getPlayBackShow();
    },
    getPlayBackShow: function() {
        var a = this, e = t.getNetAddresss("plugin.room.frontend.live-list.record");
        t._postNetWork({
            url: e,
            showToastIn: !1,
            data: {},
            success: function(t) {
                var e = t.data;
                1 == e.result ? a.setData({
                    playBackShow: 1 == e.data.result
                }) : wx.showToast({
                    icon: "none",
                    title: e.msg,
                    duration: 1500
                });
            },
            fail: function(t) {
                console.log(t.msg);
            }
        });
    },
    getBanner: function() {
        var a = this, e = t.getNetAddresss("plugin.room.frontend.live-list.banner");
        t._postNetWork({
            url: e,
            showToastIn: !1,
            data: {},
            success: function(t) {
                var e = t.data;
                1 == e.result ? a.setData({
                    liveBanner: e.data
                }) : wx.showToast({
                    icon: "none",
                    title: e.msg,
                    duration: 1500
                });
            },
            fail: function(t) {
                console.log(t.msg);
            }
        });
    },
    getRecommend: function() {
        var a = this, e = t.getNetAddresss("plugin.room.frontend.live-list.get-live-recommend");
        t._postNetWork({
            url: e,
            showToastIn: !1,
            data: {
                keyword: this.data.live_search,
                cate_id: this.data.cate_id
            },
            success: function(t) {
                var e = t.data;
                1 == e.result ? a.setData({
                    recommendData: e.data
                }) : wx.showToast({
                    icon: "none",
                    title: e.msg,
                    duration: 1500
                });
            },
            fail: function(t) {
                console.log(t.msg);
            }
        });
    },
    onReady: function() {},
    swichTabTItem: function(t) {
        var a = t.detail.index;
        this.setData({
            isLoadMore: !0,
            page: 1,
            total_page: 0,
            live_search: ""
        }), 0 == a ? (this.data.apiType = "myConcern", this.getMyConcern()) : 1 == a ? (this.data.apiType = "AllLivelist", 
        this.getAllLivelist()) : 2 == a ? (this.data.apiType = "recommend", this.getRecommend()) : 3 == a ? (this.data.apiType = "liveList", 
        this.data.status = 3, this.getLiveList(3)) : 4 == a ? (this.data.apiType = "liveList", 
        this.data.status = 2, this.getLiveList(2)) : 5 == a && (this.data.apiType = "playBack", 
        this.getplayBack());
    },
    getplayBack: function() {
        var a = this, e = t.getNetAddresss("plugin.room.frontend.live-list.play-back");
        t._postNetWork({
            url: e,
            showToastIn: !1,
            data: {
                page: 1,
                keyword: this.data.live_search,
                cate_id: this.data.cate_id
            },
            success: function(t) {
                var e = t.data;
                1 == e.result ? a.setData({
                    playBackData: e.data.data,
                    total_page: e.data.last_page
                }) : wx.showToast({
                    icon: "none",
                    title: e.msg,
                    duration: 1500
                });
            },
            fail: function(t) {
                console.log(t.msg);
            }
        });
    },
    getLiveList: function(a) {
        var e = this, i = t.getNetAddresss("plugin.room.frontend.live-list.get-live-list");
        t._postNetWork({
            url: i,
            showToastIn: !1,
            data: {
                status: a,
                page: 1,
                keyword: this.data.live_search,
                cate_id: this.data.cate_id
            },
            success: function(t) {
                var i = t.data;
                1 == i.result ? 2 == a ? e.setData({
                    total_page: i.data.last_page,
                    announceList: i.data.data
                }) : 3 == a && e.setData({
                    total_page: i.data.last_page,
                    broadcastlist: i.data.data
                }) : wx.showToast({
                    icon: "none",
                    title: i.msg,
                    duration: 1500
                });
            },
            fail: function(t) {
                console.log(t.msg);
            }
        });
    },
    getAllLivelist: function() {
        var a = this, e = t.getNetAddresss("plugin.room.frontend.live-list.get-all-live-list");
        t._postNetWork({
            url: e,
            showToastIn: !1,
            data: {
                page: 1,
                keyword: this.data.live_search,
                cate_id: this.data.cate_id
            },
            success: function(t) {
                var e = t.data;
                1 == e.result ? a.setData({
                    allLivelistData: e.data.data,
                    total_page: e.data.last_page
                }) : wx.showToast({
                    icon: "none",
                    title: e.msg,
                    duration: 1500
                });
            },
            fail: function(t) {
                console.log(t.msg);
            }
        });
    },
    getMyConcern: function() {
        var a = this, e = t.getNetAddresss("plugin.room.frontend.live-list.get-live-concern");
        t._postNetWork({
            url: e,
            showToastIn: !1,
            data: {
                page: 1,
                keyword: this.data.live_search
            },
            success: function(t) {
                var e = t.data;
                1 == e.result ? a.setData({
                    myConcern: e.data.data,
                    total_page: e.data.last_page
                }) : wx.showToast({
                    icon: "none",
                    title: e.msg,
                    duration: 1500
                });
            },
            fail: function(t) {
                console.log(t.msg);
            }
        });
    },
    onShow: function() {},
    onHide: function() {},
    onUnload: function() {},
    onPullDownRefresh: function() {},
    onReachBottom: function() {
        this.data.isLoadMore ? "recommend" !== this.data.apiType && this._getMoreData() : console.log("没有更多数据");
    },
    _getMoreData: function() {
        var a = this, e = {}, i = "", s = "";
        a.data.isLoadMore = !1, this.data.page >= this.data.total_page || (this.data.page = this.data.page + 1, 
        "myConcern" == this.data.apiType ? (i = "plugin.room.frontend.live-list.get-live-concern", 
        e = {
            page: this.data.page,
            cate_id: this.data.cate_id
        }) : "AllLivelist" == a.data.apiType ? (i = "plugin.room.frontend.live-list.get-all-live-list", 
        e = {
            page: this.data.page,
            cate_id: this.data.cate_id
        }) : "playBack" == a.data.apiType ? (i = "plugin.room.frontend.live-list.play-back", 
        e = {
            page: this.data.page,
            cate_id: this.data.cate_id
        }) : (i = "plugin.room.frontend.live-list.get-live-list", e = {
            status: this.data.status,
            page: this.data.page,
            cate_id: this.data.cate_id
        }), e.keyword = this.data.live_search, s = t.getNetAddresss(i), t._postNetWork({
            url: s,
            showToastIn: !1,
            data: e,
            success: function(t) {
                var e = t.data;
                1 == e.result ? "myConcern" == a.data.apiType ? a.setData({
                    isLoadMore: !0,
                    myConcern: a.data.myConcern.concat(e.data.data)
                }) : "playBack" == a.data.apiType ? a.setData({
                    isLoadMore: !0,
                    playBackData: a.data.playBackData.concat(e.data.data)
                }) : "AllLivelist" == a.data.apiType ? a.setData({
                    isLoadMore: !0,
                    allLivelistData: a.data.allLivelistData.concat(e.data.data)
                }) : 2 == a.data.status ? a.setData({
                    isLoadMore: !0,
                    announceList: a.data.announceList.concat(e.data.data)
                }) : 3 == a.data.status && a.setData({
                    isLoadMore: !0,
                    broadcastlist: a.data.broadcastlist.concat(e.data.data)
                }) : a.setData({
                    page: a.data.page - 1,
                    isLoadMore: !1
                });
            },
            fail: function(t) {
                console.log(t.msg);
            }
        }));
    },
    onShareAppMessage: function() {},
    golivePage: function(t) {
        var a = t.currentTarget.dataset.id, e = t.currentTarget.dataset.status, i = t.currentTarget.dataset.memberid;
        console.log(t), 1 == e ? wx.navigateTo({
            url: "/packageD/directSeeding/livePage/livePage?id=" + a + "&playerType=live"
        }) : wx.navigateTo({
            url: "/packageD/directSeeding/anchorDetail/anchorDetail?id=" + i
        });
    },
    gopage: function(t) {
        var a = t.currentTarget.dataset.status, e = t.currentTarget.dataset.id, i = t.currentTarget.dataset.backid;
        1 == a ? wx.navigateTo({
            url: "/packageD/directSeeding/livePage/livePage?id=" + e + "&playerType=live"
        }) : 2 == a && wx.navigateTo({
            url: "/packageD/directSeeding/livePage/livePage?id=" + e + "&playerType=video&backid=" + i
        });
    },
    golistPage: function(t) {
        var a = t.currentTarget.dataset.status, e = t.currentTarget.dataset.id, i = t.currentTarget.dataset.backid;
        3 == a ? wx.navigateTo({
            url: "/packageD/directSeeding/livePage/livePage?id=" + e + "&playerType=live"
        }) : 2 == a ? wx.navigateTo({
            url: "/packageD/directSeeding/foreshow/foreshow?id=" + e
        }) : 4 == a && wx.navigateTo({
            url: "/packageD/directSeeding/livePage/livePage?id=" + e + "&playerType=video&backid=" + i
        });
    },
    goPlayBackData: function(t) {
        var a = t.currentTarget.dataset.roomid, e = t.currentTarget.dataset.backid;
        wx.navigateTo({
            url: "/packageD/directSeeding/livePage/livePage?id=" + a + "&playerType=video&backid=" + e
        });
    },
    goforeshow: function(t) {
        var a = t.currentTarget.dataset.id;
        wx.navigateTo({
            url: "/packageD/directSeeding/foreshow/foreshow?id=" + a
        });
    },
    onImageLoad: function(t) {
        var a = t.target.dataset.index, e = t.target.dataset.seltype, i = null, s = t.detail.width / t.detail.height;
        if ("myConcern" == e) {
            i = this.data.myConcern[a];
            var o = this.data.myConcern_activitys1, n = this.data.myConcern_activitys2;
            this.data.my_colOneHeight <= this.data.my_colTwoHeight ? (this.data.my_colOneHeight += 176 / s + 60, 
            o.push(i)) : (this.data.my_colTwoHeight += 176 / s + 60, n.push(i)), this.setData({
                myConcern_activitys1: o,
                myConcern_activitys2: n
            });
        } else if ("recommend" == e) {
            i = this.data.recommendData[a];
            var l = this.data.recommendData_activitys1, c = this.data.recommendData_activitys2;
            this.data.re_colOneHeight <= this.data.re_colTwoHeight ? (this.data.re_colOneHeight += 176 / s + 60, 
            l.push(i)) : (this.data.re_colTwoHeight += 176 / s + 60, c.push(i)), this.setData({
                recommendData_activitys1: l,
                recommendData_activitys2: c
            });
        } else if ("AllLivelist" == e) {
            i = this.data.allLivelistData[a];
            var d = this.data.allLivelistData_activitys1, r = this.data.allLivelistData_activitys2;
            this.data.all_colOneHeight <= this.data.all_colTwoHeight ? (this.data.all_colOneHeight += 176 / s + 60, 
            d.push(i)) : (this.data.all_colTwoHeight += 176 / s + 60, r.push(i)), this.setData({
                allLivelistData_activitys1: d,
                allLivelistData_activitys2: r
            });
        } else if ("liveList_1" == e) {
            i = this.data.broadcastlist[a];
            var h = this.data.broadcastlist_activitys1, g = this.data.broadcastlist_activitys2;
            this.data.br_colOneHeight <= this.data.br_colTwoHeight ? (this.data.br_colOneHeight += 176 / s + 60, 
            h.push(i)) : (this.data.br_colTwoHeight += 176 / s + 60, g.push(i)), this.setData({
                broadcastlist_activitys1: h,
                broadcastlist_activitys2: g
            });
        } else if ("liveList_2" == e) {
            i = this.data.announceList[a];
            var v = this.data.announceList_activitys1, p = this.data.announceList_activitys2;
            this.data.an_colOneHeight <= this.data.an_colTwoHeight ? (this.data.an_colOneHeight += 176 / s + 60, 
            v.push(i)) : (this.data.an_colTwoHeight += 176 / s + 60, p.push(i)), this.setData({
                announceList_activitys1: v,
                announceList_activitys2: p
            });
        } else if ("playBack" == e) {
            i = this.data.playBackData[a];
            var u = this.data.playBackData_activitys1, y = this.data.playBackData_activitys2;
            this.data.pl_colOneHeight <= this.data.pl_colTwoHeight ? (this.data.pl_colOneHeight += 176 / s + 60, 
            u.push(i)) : (this.data.pl_colTwoHeight += 176 / s + 60, y.push(i)), this.setData({
                playBackData_activitys1: u,
                playBackData_activitys2: y
            });
        }
    },
    onImageError: function(t) {
        var a = t.target.dataset.index, e = t.target.dataset.seltype;
        console.log("图片加载发生错误"), this.onImageLoad({
            target: {
                dataset: {
                    index: a,
                    seltype: e
                }
            },
            detail: {
                width: 2340,
                height: 1080
            }
        });
    },
    searchConfirm: function() {
        "myConcern" == this.data.apiType ? (this.data.my_colOneHeight = 0, this.data.my_colTwoHeight = 0, 
        this.setData({
            myConcern: [],
            myConcern_activitys1: [],
            myConcern_activitys2: []
        }), this.getMyConcern()) : "recommend" == this.data.apiType ? (this.data.re_colOneHeight = 0, 
        this.data.re_colTwoHeight = 0, this.setData({
            recommendData: [],
            recommendData_activitys1: [],
            recommendData_activitys2: []
        }), this.getRecommend()) : "liveList" == this.data.apiType ? 3 == this.data.status ? (this.data.br_colOneHeight = 0, 
        this.data.br_colTwoHeight = 0, this.setData({
            broadcastlist: [],
            broadcastlist_activitys1: [],
            broadcastlist_activitys2: []
        }), this.getLiveList(3)) : 2 == this.data.status && (this.data.an_colOneHeight = 0, 
        this.data.an_colTwoHeight = 0, this.setData({
            announceList: [],
            announceList_activitys1: [],
            announceList_activitys2: []
        }), this.getLiveList(2)) : "playBack" == this.data.apiType ? (this.data.pl_colOneHeight = 0, 
        this.data.pl_colTwoHeight = 0, this.setData({
            playBackData: [],
            playBackData_activitys1: [],
            playBackData_activitys2: []
        }), this.getplayBack()) : "AllLivelist" == this.data.apiType && (this.data.all_colOneHeight = 0, 
        this.data.all_colTwoHeight = 0, this.setData({
            allLivelistData: [],
            allLivelistData_activitys1: [],
            allLivelistData_activitys2: []
        }), this.getAllLivelist());
    },
    searchbtn: function(t) {
        var a = t.detail.value;
        this.setData({
            live_search: a
        });
    }
});